]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
timeLimitsManager: Factor out wellbeing-daily-limit-enabled
authorIgnacy Kuchciński <ignacykuchcinski@gnome.org>
Sat, 22 Nov 2025 00:45:32 +0000 (01:45 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 17 Dec 2025 12:14:17 +0000 (12:14 +0000)
Factor out wellbeing-daily-limit-enabled specific for the wellbeing
screen time limits functionality to a separate function, which will make
it easier in the future to make the daily-limit-enabled property also
handle parental controls session limits functionality.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3977>

js/misc/timeLimitsManager.js

index e1a22f0f82771af122dbd323b6836d2fbbed8ef4..2793687dce7f3cea462b9702e18cb93b07abca71 100644 (file)
@@ -876,7 +876,7 @@ export const TimeLimitsManager = GObject.registerClass({
      * @returns {number}
      */
     _calculateDailyLimitReachedAtSecs(nowSecs, dailyLimitSecs, startOfTodaySecs) {
-        console.assert(this.dailyLimitEnabled,
+        console.assert(this.wellbeingDailyLimitEnabled,
             'Daily limit reached-at time only makes sense if limits are enabled');
 
         // NOTE: This might return -1.
@@ -1045,6 +1045,15 @@ export const TimeLimitsManager = GObject.registerClass({
         return this._parentalControlsManager.sessionLimitsEnabled();
     }
 
+    /**
+     * Whether the wellbeing daily limit is enabled.
+     *
+     * @type {boolean}
+     */
+    get wellbeingDailyLimitEnabled() {
+        return this._screenTimeLimitSettings.get_boolean('daily-limit-enabled');
+    }
+
     /**
      * The time when the daily limit will be reached. If the user is currently
      * active, and has not reached the limit, this is a non-zero value in the
@@ -1060,7 +1069,7 @@ export const TimeLimitsManager = GObject.registerClass({
         case TimeLimitsState.DISABLED:
             return 0;
         case TimeLimitsState.ACTIVE: {
-            if (!this.dailyLimitEnabled)
+            if (!this.wellbeingDailyLimitEnabled)
                 return 0;
 
             const nowSecs = this.getCurrentTime();
@@ -1098,7 +1107,7 @@ export const TimeLimitsManager = GObject.registerClass({
      * @type {boolean}
      */
     get dailyLimitEnabled() {
-        return this._screenTimeLimitSettings.get_boolean('daily-limit-enabled');
+        return this.wellbeingDailyLimitEnabled;
     }
 
     /**